package com.ittable.datasource.route.dynamicdatasource;

/**
 * @author srh
 * @date 2020/12/20
 **/
public class DynamicDataSourceContextHolder {

    private static final ThreadLocal<DynamicDataSourceTypeEnum> CONTEXT_HOLDER;

    static {
        CONTEXT_HOLDER = new ThreadLocal<>();
    }

    public static void setDataSourceType(DynamicDataSourceTypeEnum type) {
        CONTEXT_HOLDER.set(type);
    }

    public static DynamicDataSourceTypeEnum getDataSourceType() {
        return CONTEXT_HOLDER.get();
    }

    public static void clearDataSourceType() {
        CONTEXT_HOLDER.remove();
    }
}
